package com.yunxun.coinmessage.config;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class ConfigJson {
    public String getImageRealPath(String configPath) {
        FileReader fr = null;
        BufferedReader bufr = null;
        try {
            fr = new FileReader(configPath);
            bufr = new BufferedReader(fr);
            StringBuilder stringBuilder=new StringBuilder();
            String line = null;
            while ((line = bufr.readLine()) != null) {
                //判读是否包含bathPath，有的话则表明该行是上传图片的根路径
                    stringBuilder.append(line);
            }
            JSONObject jsonObject= new JSONObject(stringBuilder.toString());
              return jsonObject.getString("bathPath");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
                  if(bufr!=null){
                      try {
                          bufr.close();
                      }catch (IOException e){
                          e.printStackTrace();
                      }
                  }
                  if(fr!=null){
                      try {
                          fr.close();
                      }catch (IOException e){
                          e.printStackTrace();
                      }
                  }
        }
        return "";
    }

}
